﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Hotel.Classes.Helper;
using Hotel.Models.Entity;

namespace Hotel.Models.DataAccess
{
    public class DAGroupService
    {

        public static List<GroupService> GetListGroupService(int groupServiceID)
        {
            DataTable dt;
            List<GroupService> listFloor = new List<GroupService>();
            using (DBManager dbManager = new DBManager("stp_Get_GroupService"))
            {
                dbManager.Add("p_PK_GroupService", groupServiceID);
                dbManager.Add("IsDelete", 0);
                dt = dbManager.GetDatatable();
            }
            foreach (DataRow dr in dt.Rows)
            {
                GroupService floor = new GroupService();
                floor.PkGroupService = DataHelper.GetInt(dr, "PK_GroupServiceID");
                floor.Name = DataHelper.Get(dr, "Name");
                listFloor.Add(floor);
            }
            return listFloor;
        }
        public static bool DeleteGroupService(int groupServiceID)
        {
            using (DBManager dbManager = new DBManager("stp_Get_GroupService"))
            {
                try
                {
                    dbManager.Add("PK_GroupServiceID", groupServiceID);
                    dbManager.Add("IsDelete", 1);
                    dbManager.ExecuteNonQuery();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }

            }
        }

        //Insert : isUpdate = false
        //Update : isUpdate = true
        public static bool SaveGroupService(GroupService groupService, bool isUpdate)
        {
            using (DBManager dbManager = new DBManager("stp_Create_GroupService"))
            {
                try
                {
                    dbManager.Add("p_PK_GroupServiceID", groupService.PkGroupService);
                    dbManager.Add("p_Name", groupService.Name);
                    dbManager.Add("IsUpdate", isUpdate);
                    dbManager.ExecuteNonQuery();
                    return true;
                }
                catch (Exception)
                {

                    return false;
                }

            }
        }
    }
}